<?php

namespace App\Http\Resources\Invoice;

use App\Http\Resources\BaseResource;
use App\Models\Invoice\InvoiceHistoryModel;
use Illuminate\Http\Request;

class AppInvoiceHistoryListResource extends BaseResource
{

    /**
     * @param Request $request
     * @return array
     */
    public function toArray($request): array
    {
        return [
            "id"                    => (string)$this->id,
            "businessType"          => (string)$this->businessType,
            "businessTypeText"      => translateEnumCodeToCn(
                InvoiceHistoryModel::BUSINESS_TYPE_TEXT,
                $this->businessType
            ),
            "invoiceType"           => $this->invoiceType,
            "invoiceTypeText"       => translateEnumCodeToCn(
                InvoiceHistoryModel::INVOICE_TYPE_TEXT,
                $this->invoiceType
            ),
            "headerType"            => (string)$this->headerType,
            "headerTypeText"        => translateEnumCodeToCn(
                InvoiceHistoryModel::HEADER_TYPE_TEXT,
                $this->headerType
            ),
            "status"                => (string)$this->status,
            "statusText"            => translateEnumCodeToCn(
                InvoiceHistoryModel::STATUS_TEXT,
                $this->status
            ),
            "invoiceTotalAmount"    => (string)$this->invoiceTotalAmount,
            "invoiceTaxTotalAmount" => (string)$this->invoiceTaxTotalAmount,
            "blueTaxValueTotal"     => (string)$this->blueTaxValueTotal,
            "createTime"            => $this->createdAt->format("Y-m-d H:i:s"),
            "blueInvoiceOssFile"    => $this->blueInvoiceOssFile,
            "redInvoiceOssFile"     => $this->redInvoiceOssFile,
            "invoiceTitle"          => $this->invoiceTitle
        ];
    }
}
